package com.xjtu.chapter08.thread;

/**
 * @author yjq
 * @version 1.0
 * @date 2021/8/29 20:25
 */
//分别用继承方法和实现方法创建两个线程，Wolf类实现Runnable接口，Lamb类继承于Thread
class Lamb2 extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 2; i++) {
            System.out.println("I am a happy lamb" + i);
        }
    }
}

class Wolf2 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 2; i++) {
            System.out.println("I am a bad wolf" + i);
        }
    }
}

public class ThreadTest2 {
    public static void main(String[] args) {
        Lamb2 mie = new Lamb2();
        Wolf2 hui = new Wolf2();
        Thread t1 = new Thread(hui);
        mie.start();
        t1.start();
        for (int i = 0; i < 2; i++) {
            System.out.println("main thread is running");
        }
    }
}
